package ca.etsmtl.log430.lab3;

import java.util.Observable;

/**
 * Upon notification, this class lists the students that were read into the
 * vector stored in the CommonData class.
 * 
 * @author A.J. Lattanze, CMU
 * @version 1.2, 2011-Feb-24
 */

/*
 * Modification Log **********************************************************
 * 
 * v1.2, R. Champagne, 2011-Feb-24 - Various refactorings, conversion of
 * comments to javadoc format.
 * 
 * v1.1, R. Champagne, 2002-Jun-19 - Adapted for use at ETS.
 * 
 * v1.0, A.J. Lattanze, 12/29/99 - Original version.
 * ***************************************************************************
 */

public class ListStudents extends Communication implements Runnable {
	boolean Stop = false;

	public ListStudents(Integer RegistrationNumber, String ComponentName) {
		super(RegistrationNumber, ComponentName);

	} // Constructor

	@Override
	public void update(Observable Thing, Object NotificationNumber) {

		if (SYSTEM_SHUT_DOWN_ID.compareTo((Integer) NotificationNumber) == 0) {
			Stop = true;

		} else {
			if (registrationNumber.compareTo((Integer) NotificationNumber) == 0) {
				Displays Display = new Displays();
				Display
						.displayStudentList(CommonData.theListOfStudents.listOfStudents);

			} // if
		} // if

	} // update

	public void run() {
		System.out.println("\nListStudents Component Started...");

		try {
			while (!Stop) {

				Thread.sleep(1000);

			} // while

			System.out.println("\nListStudents Component Shutdown...");

		} catch (Exception e) {

			System.out.println("Exception occured in ListStudents.run(): " + e);

		} // try-catch

	} // run

} // ListStudents
